#pragma once 

namespace my_map
{
    template<class K, class V>
    class map 
    {
        struct KeyMap 
        {
            const K& operator()(const pair<K, V>& kv) 
            {
                return kv.first;
            }
        };
    public:
        typedef typename RBTree<K, pair<K, V>, KeyMap>::iterator iterator;
        iterator begin() { return _t.begin(); }
        iterator end() { return _t.end(); }
        pair<iterator, bool> insert (const pair<K, V>& kv) { return _t.insert(kv); }
        V& operator[](const K& k)
        {
            pair<iterator, bool> ret = insert(make_pair(k, V()));
            return (ret.first)->second;
        }
    private:
        RBTree<K, pair<K, V>, KeyMap> _t;
    };
}
